package com.dy.mapper;

import com.dy.domain.Shangpin;
import com.dy.domain.Tu;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShangpinMapper {


    List<Shangpin> mohu(String ming);

    @Insert("insert into shangpin values(null,#{sname},#{price},#{lei},1)")
    void add(Shangpin shangpin);

    @Select("select * from shangpin where isdel = 1 and sid = #{value}")
    Shangpin huixian(Integer sid);

    @Update("update shangpin set sname = #{sname},price = #{price},lei = #{lei} where sid = #{sid}")
    void update(Shangpin shangpin);

    @Update("update shangpin set isdel = 0 where sid = #{value}")
    void del(Integer sid);

    @Select("select * from shangpin where isdel = 1")
    List<Shangpin> findall();

    @Select("SELECT lei NAME,COUNT(lei) VALUE FROM shangpin GROUP BY lei")
    List<Tu> find();
}
